//
//  UIImageView+WebImage.swift
//  WeiboSwift
//
//  Created by hfwd on 2017/6/6.
//  Copyright © 2017年 hfwd. All rights reserved.
//

import SDWebImage

extension UIImageView {
    
    func sc_setImage(urlString: String?, placeHolderImage: UIImage? , isAvatar: Bool = false) {
        
        guard let urlString = urlString,
              let url = URL(string: urlString)
        
            else {
            
                image = placeHolderImage
                
                return
        }
        
        sd_setImage(with: url, placeholderImage: placeHolderImage, options: []) { (image, _, _, _) in
            
            if isAvatar {
                
                self.image = image?.adjustImage(size: self.bounds.size)
            }
        }
    }
}
